﻿/*版权声明
 * 
 * 本 河北大学管理学院信息管理系网站 由
 * 河北大学 信管团队 开发
 * 如有任何疑问请联系开发人员
 * 
 * 项目开发者：朱胜贤、孙旭峰、水亚亚、张文元、项玥、吕芳、吴凡、谢静、李亚慧
 * 
 * 如有任何疑问请联系：河北大学信管团队
 * QQ：196396337
 * Email:zagelover@163.com
 * HomePage：http://sxgzs.com/
 * 
 * CopyRight (c) 河北大学信管团队 2010~2020
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Student : System.Web.UI.Page
{
    private void classbind()
    {
        string sql = "select classID,className from Class_Info order by className desc";
        rptClass.DataSource = DataAccess.GetDataTable(sql, null);
        rptClass.DataBind();
    }
    private void stubind()
    {
        string sql = "select stuID,stuName from Student_Info order by stuName desc";
        rptStu.DataSource = DataAccess.GetDataTable(sql, null);
       rptStu.DataBind();
    }
   
    private void dtStubind(string stuClass)
    {
        dtStu.Visible = true;
      
        SqlParameter[] para1 = { new SqlParameter("@stuClass", SqlDbType.NVarChar) };
        string sql1 = "select stuID,stuName from Student_Info where stuClass= @stuClass";
        para1[0].Value = stuClass;
        DataSet ds = DataAccess.GetDataSet(sql1, para1);
        dtStu.DataSource = ds;
        dtStu.DataBind();
   }
   
    void judge(string ID)
    {
       
        string[] sArray = ID.Split(',');
        string ID1 = sArray[0];
        string ID2 = sArray[1];
        if (ID2 == "1")
        {
            dtStu.Visible = true;
          
            SqlParameter[] para = { new SqlParameter("@classID", SqlDbType.Int) };
           string sql = "select className,classInfo from Class_Info where classID= @classID";
            para[0].Value =ID1;
            DataTable dt = DataAccess.GetDataTable(sql, para);
            if (dt.Rows.Count > 0)
            {  dtStubind(dt.Rows[0]["className"].ToString());
                lblTitleTop.Text = "班级简介 >" + dt.Rows[0]["className"].ToString();
                    lblTitle.Text = dt.Rows[0]["className"].ToString();
                lblContent.Text = dt.Rows[0]["classInfo"].ToString();
                dtStu.Visible = true;
             
            }
           
      
        }
        else
        {
            dtStu.Visible = false;
            SqlParameter[] para = { new SqlParameter("@stuID", SqlDbType.Int) };
            string sql = "select stuName,stuSex,stuClass,stuInfo from Student_Info where stuID= @stuID";
            para[0].Value = ID1;
            DataTable dt = DataAccess.GetDataTable(sql, para);
            if (dt.Rows.Count > 0)
            {
                lblTitleTop.Text = "学生简介 >" + dt.Rows[0]["stuName"].ToString() ;
                lblTitle.Text = dt.Rows[0]["stuName"].ToString();
                lblsex.Text = "性别：" + dt.Rows[0]["stuSex"].ToString();
                lblClass.Text = "所在班级：" + dt.Rows[0]["stuClass"].ToString();
                lblContent.Text =dt.Rows[0]["stuInfo"].ToString();
            }
        }
    
     }
   
 
  
   
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            classbind();
            stubind();
            string ID = Request.QueryString["ID"].ToString();
           if (ID == "")
            {

               
            }
            else
            {

                judge(ID);
            }
        }
        
      
    }




    
}
